package com.yx.cloud.product.gyro.convert;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtils {
    /**
     * 使用时间戳转换成日期格式
     *
     * @param seconds
     * @param format
     * @return
     */
    public static String timeStamp2Date(String seconds, String format) {
        if (seconds == null || seconds.isEmpty() || seconds.equals("null")) {
            return "";
        }
        if (format == null || format.isEmpty()) {
            format = "yyyy-MM-dd HH:mm:ss";
        }
        SimpleDateFormat sdf = new SimpleDateFormat(format);

        return sdf.format(new Date(Long.valueOf(seconds + "000")));
    }

    public static String getFormatedDateString(long time) {
//        TimeZone timeZone;
//        timeZone = TimeZone.getTimeZone("GMT+8:00");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //sdf.setTimeZone(timeZone);
        return sdf.format(new Date(time));
    }
}
